<?phpclass BusinessAction extends Action {	protected function _initialize() {
		$freeAuth = array('login', 'verify');
		if (!in_array(ACTION_NAME, $freeAuth)) {
			empty($_SESSION['BusinessAuthInfo']) ? redirect(U('index/login')) : 1 ;
		}		if(C('IS_DATA')){		    echo '后台数据维护中。。';exit;		}
	}		/* 控制器 验证码 */
	public function verify() {		ob_clean();
		$type	 =	isset($_GET['type'])?$_GET['type']:'gif';
		import('@.ORG.Image');
		Image::buildImageVerify(4,1,$type);
	}		/* 控制器 登录 */
	public function login() {
		if (empty($_POST)) {
			$this->display();
			exit;
		}
		$this->checkLogin($_POST);
	}
	/* 私有 登录验证 */
	private function checkLogin($data) {
		if (empty($data['tel']))
			$this->error('手机号不能为空');
		if (empty($data['password']))
			$this->error('密码不能为空');
				if (md5($data['verify']) != $_SESSION['verify'])
			$this->error('验证码不正确!');				
		$model = M('admin_business');
		$map['tel'] = $data['tel'];
		$res = $model->where($map)->find();
		if (!$res)
			$this->error('用户不存在');
		if ($res['password'] != md5($data['password']))
			$this->error('密码不正确');		if($res['purview']!=0){		    $this->error('只允许店长登陆');		}		$ress=M('business')->where("business_id=$res[shop_id]")->find();		if($ress['statuss']==2){		    $this->error('等待审核通过后方能登陆');		}
		$_SESSION['language'] = $data['language'];
		$a = M("admin_business");
		$admin['login_time'] = time();
		$admin['last_ip'] = get_client_ip();
		$admin['login_count'] = array('exp', 'login_count+1');
		$a->where($map)->save($admin);
		$_SESSION[ucfirst(GROUP_NAME) . 'AuthInfo'] = $res;
		$_SESSION['tel'] = $data['tel'];
		$_SESSION['userID'] = $res['id'];		
		redirect(U('index'));
	}	}?>